# -*- coding:utf-8
"""
作者: Jia
日期: 2022年04月17日
描述: https://leetcode-cn.com/problems/maximum-subarray/
"""
from typing import List


class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        max_val = -10e5
        sum_val = -10e5
        for num in nums:
            sum_val = max(num, sum_val + num)
            max_val = max(max_val, sum_val)
        return max_val
